package com.chinawlx.wlxteacher.widget;

import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.TextView;
import android.widget.Toast;

import com.chinawlx.wlxteacher.R;
import com.chinawlx.wlxteacher.base.WLXApplication;

/**
 * Created by wlx on 16/9/5.
 */
public class WLXCustomToast {
    //  创建一个toast
    private static Toast toast = new Toast(WLXApplication.myApplication);

    private static View layout = LayoutInflater.from(WLXApplication.myApplication).inflate(R
            .layout.item_toast, null);
    private static TextView tv = (TextView) layout.findViewById(R.id.toast_context);

    static {
        toast.setView(layout);
        toast.setDuration(Toast.LENGTH_SHORT);
    }

    /**
     * 弹出toast的方法
     */
    public static void show(String toastText) {
        tv.setText(toastText);
        toast.setGravity(Gravity.CENTER_VERTICAL, 0, 0);
        toast.show();
    }

    /**
     * 位置在顶部的Toast(上传视频和图片的进度)
     */
    public static void showTopToast(String toastText) {
        tv.setText(toastText);
        toast.setGravity(Gravity.TOP, 0, 0);
        toast.show();
    }

}
